<template>
    <transition name="modal">
      <div class="modal-mask">
        <div class="modal-wrapper">
          <div class="modal-container">

            <div class="modal-header">
              <slot name="header">
                <img class="login-logo" src="/static/logo.png"/>
              </slot>
            </div>

            <div class="modal-body">
              <slot name="body">
                <form method="post" id="login_form" v-on:submit.prevent="submit">
                  <input class="form-control" name="username" placeholder="账号" v-model="username"/>

                  <input class="form-control" name="password" type="password" v-model="password" placeholder="密码">

                  <button class="btn-login btn-blue"  @click="login(username,password)">登录</button>
                </form>
              </slot>
            </div>

            <div class="modal-close" @click="$emit('close')">
              <slot name="close">

              </slot>
            </div>
          </div>
        </div>
      </div>
    </transition>
</template>

<script>

  export default {
    name: 'loginModal',
    components: {},
    data (){
      return {
        username:'',
        password:''
      }
    }
  }
</script>

<style scoped>
  .modal-header{
    border-bottom: none;
    text-align: center;
  }

  .login-logo {
    margin-top: 40px;
  }

  .modal-mask {
    position: fixed;
    z-index: 9998;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, .5);
    display: table;
    transition: opacity .3s ease;
  }

  .modal-wrapper {
    display: table-cell;
    vertical-align: middle;
  }

  .modal-container {
    position: relative;
    width: 400px;
    height: 480px;
    border-radius: 3px;
    border-top-right-radius: 0;
    margin: 0 auto;
    padding: 20px 30px;
    background-color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .33);
    transition: all .3s ease;
    font-family: Helvetica, Arial, sans-serif;
  }

  .modal-header h3 {
    margin-top: 0;
    color: #42b983;
  }

  .modal-body {
    margin: 0 auto;
  }

  .modal-body .form-control {
    width: 300px;
    margin: 30px auto 0;
  }

  .modal-body .btn-login {
    margin: 30px 5px;
    width: 300px;
    outline: none;
  }

  .btn-blue {
    border-radius: 3px;
    border: 0;
    background-color: #238ae5;
    color: #fff;
    padding: 10px 0;
  }


  .modal-close {
    cursor: pointer;
    position: absolute;
    right: -1px;
    top: 0;
  }

  .modal-close:before {
    background: #fff;
    color: #bbb;
    content: "\00D7";
    font-size: 32px;
    font-weight: normal;
    height: 46px;
    width: 46px;
    line-height: 46px;
    position: absolute;
    text-align: center;

  }

  .modal-enter {
    opacity: 0;
  }

  .modal-leave-active {
    opacity: 0;
  }

  .modal-enter .modal-container,
  .modal-leave-active .modal-container {
    -webkit-transform: scale(1.1);
    transform: scale(1.1);
  }

  @media screen and (max-width: 768px) {
    .modal-container {
      position: relative;
      width: 90%;
      height: 400px;
      margin: 0 auto;
      padding: 20px;
    }

    .modal-body .form-control {
      width: 100%;
      margin: 15px auto 0;
    }

    .modal-body .btn-login {
      margin: 20px auto;
      width: 100%;
    }

    .modal-close {
      right: 46px;
      top: 0;
    }
  }
</style>
